<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>诱导语音</title>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../css/voice.css" />
</head>

<body>
	<div id="app" v-cloak>
		<div class="wrap flex-wrap flex-vertical">
			<div :class="['call-wrap', 'flex-con', 'sex' + sex]">
				<div class="random-avatar">
					<img :src="avatar + '?imageView2/1/w/100/h/100'" alt="">
				</div>
				<div class="random-text">{{name}}</div>
				<div class="control-wrap">
					<div class="random-cancel" @click="cancel"></div>
					<div class="random-answer iconfont icon-call" @click="recharge"></div>
				</div>
			</div>
		</div>
	</div>
</body>

</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script>
	var app;
	apiready = function () {
		app = new Vue({
			el: '#app',
			data: {
				avatarList: ['http://file.kedouwoapp.com/FskDY247ryac9clN6_5HEPBlKtfF', 'http://file.kedouwoapp.com/Fu-_OXsOH_pP0Y4UgZWN631bfidR', 'http://file.kedouwoapp.com/FrMCfvYA1f-uR0kk2r3lmvEWPKc3', 'http://file.kedouwoapp.com/FtjgoZmXKElf-8v9dxiR_gIdAwqX', 'http://file.kedouwoapp.com/Fpod727zqnVCEqfTX2Ii1i2o5grZ'],
				avatar: 'http://file.kedouwoapp.com/FqLs5WZ-k7qwd3zVImOCf_oPyG9D',
				names: ['兮兮', '执画素颜', '转眼逝', '宁负天下不负你', '待姐长发及腰一把勒死你', '干物女ノ', '许你春秋', '小诗人', '心悦君兮', '黑夜亦亮丽', '阙歌', '公主息怒'],
				name: '',
				sex: api.pageParam.sex
			},
			created: function () {
				this.name = this.names[parseInt(10 * Math.random())];
				this.avatar = this.avatarList[parseInt(5 * Math.random())];
			},
			mounted: function () {
				var _this = this;
				api.addEventListener({
          name: 'viewappear'
        }, function(ret, err) {
          _this.playRing();
        });
			},
			methods: {
				// 振铃
        playRing: function () {
          var _this = this;
          api.startPlay({
            path: 'widget://res/ring.mp3'
          }, function (ret, err) {
            if (ret) {
              _this.playRing();
            }
          });
				},
				
				recharge: function () {
					var _this = this;
					api.stopPlay();
					api.openWin({
						name: 'recharge',
						url: 'recharge.html',
					})
				},

				cancel: function () {
					api.sendEvent({
						name: 'refreshHome',
						extra: {
							key: 'value'
						}
					});
					api.closeWin();
				}
			}
		})

	}
</script>